package flc.ast.fragment;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import flc.ast.R;
import flc.ast.activity.SelLevelActivity;
import flc.ast.databinding.FragmentGuessBinding;
import stark.common.basic.base.BaseNoModelFragment;
import stark.common.basic.event.EventStatProxy;
import stark.common.basic.utils.FastClickUtil;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link GuessFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class GuessFragment extends BaseNoModelFragment<FragmentGuessBinding> {

    private int selPosition=0;

    @Override
    protected int onCreate() {
        return R.layout.fragment_guess;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent5(getActivity(), mDataBinding.event5Container);
        mDataBinding.ivGuessImg.setOnClickListener(this);
        mDataBinding.ivPrevious.setOnClickListener(this);
        mDataBinding.ivNext.setOnClickListener(this);
        mDataBinding.tvStartChallenge.setOnClickListener(this);
    }

    @Override
    protected void onClickCallback(View v) {
        if (FastClickUtil.isFastClick()) return;
        switch (v.getId()){
            case R.id.ivPrevious:
                if (selPosition==0){
                    selPosition=2;
                }else {
                    selPosition--;
                }
                if (selPosition==0){
                    mDataBinding.ivGuessImg.setImageResource(R.drawable.kp_cys1);
                }else if (selPosition==1){
                    mDataBinding.ivGuessImg.setImageResource(R.drawable.kp_cys2);
                }else if (selPosition==2){
                    mDataBinding.ivGuessImg.setImageResource(R.drawable.kp_cys3);
                }
                break;
            case R.id.ivNext:
                if (selPosition==2){
                    selPosition=0;
                }else {
                    selPosition++;
                }
                if (selPosition==0){
                    mDataBinding.ivGuessImg.setImageResource(R.drawable.kp_cys1);
                }else if (selPosition==1){
                    mDataBinding.ivGuessImg.setImageResource(R.drawable.kp_cys2);
                }else if (selPosition==2){
                    mDataBinding.ivGuessImg.setImageResource(R.drawable.kp_cys3);
                }
                break;
            case R.id.tvStartChallenge:
                SelLevelActivity.kind=selPosition;
                startActivity(SelLevelActivity.class);
        }
    }

    @Override
    protected void initData() {

    }
}